<template>
    <view class="content">
        <view class="fixed-action-wrap" v-if="!state.info.state">
            <view class="fixed-action-wrap-button" @click="update">已完成?</view>
        </view>
    </view>
</template>
<script setup>
import { reactive,getCurrentInstance } from 'vue';
import { onLoad } from '@dcloudio/uni-app';

const {proxy}=getCurrentInstance()
const state=reactive({
    info:{}
})


async function update() {
    uni.showModal({
		title: '提示',
		content: '确定结束订单？',
		success: async function (modalRes) {
			if (modalRes.confirm) {
                uni.showLoading()
				const res = await proxy.request('/sys/workorder/complete', {id:state.info.id},{
                    method:"GET"
                })
				if (res.code == 200) {
					setTimeout(() => {
                        uni.$u.toast('订单已完成');
                        uni.hideLoading()
                        uni.navigateBack()
                    }, 750);
				}
			} else if (modalRes.cancel) {
				console.log('用户点击取消');
			}
		}
	});
   
}
onLoad((option)=>{
    state.info=JSON.parse(option.info)
    console.log(state.info)
})
</script>

<style lang="sass">

</style>


<style lang="scss" scoped>
.fixed-action-wrap {
    position: fixed;
    left: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 128rpx;
    padding: 32rpx;
    padding-bottom: env(safe-area-inset-bottom);
    box-sizing: border-box;

    &-button {
        display: flex;
        align-items: center;
        justify-content: center;
        width: calc(100% - 24px);
        height: 80rpx;
        background: #F2CB51;
        border-radius: 58rpx 58rpx 58rpx 58rpx;
    }
}
</style>